require('../less/courseDetail.less')

require('../fonts/iconfont.css')



document.ready(function () {
    const coursedetailname = document.querySelector("#coursedetailname")  //获取name

    const coursedetailimgurl = document.querySelector("#coursedetailimgurl") //获取imgurl

    const coursedetaildesc = document.querySelector("#coursedetaildesc") //* / / / 获取desc

    const calorie = document.querySelector("#calorie")          //卡路里calorie

    const timeid = document.querySelector("#timeid")   //时间timeid

    const frequency = document.querySelector("#frequency")  //频率frequency

    const instrument = document.querySelector("#instrument")  //器械

    /**
        * 是否登录
        */
    utils.registers()

    //获取地址中的id参数
    console.log(location.search.split("=")[1]);



    function getDetail() {
        let dizhiid = location.search.split("=")[1]
        // console.log(dizhiid);

        //发请求
        $http.get(`/sports/courseDetail?id=${dizhiid}`, function (res) {
            //  console.log(res);
            if (res.status === 0) {
                //渲染数据

                coursedetailname.textContent = res.data.name

                coursedetaildesc.textContent = res.data.desc

                coursedetailimgurl.src = "http://139.9.177.51:8099" + res.data.imgurl


                calorie.textContent = res.data.calorie


                timeid.textContent = res.data.timeid  //时间
                //console.log(timeid); 
                /*  timeid.textContent = value.toString(res.data.timeid) */

                frequency.textContent = res.data.frequency

                instrument.textContent = res.data.instrument

                const fragments = res.data.fragments    //获取视频片段
                //将视频片段存储在本地存储中
                localStorage.setItem("fragments", JSON.stringify(fragments))


                console.log(fragments);
            }
        })
    }
    getDetail()




})